package com.miplus.ccrm.core.controller;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.miplus.ccrm.common.CmdResVo;
import com.miplus.ccrm.common.JSysUser;
import com.miplus.ccrm.common.PageData;
import com.miplus.ccrm.common.R;
import com.miplus.ccrm.core.controller.vo.LabelResVo;
import com.miplus.ccrm.core.controller.vo.conf.*;
import com.miplus.ccrm.core.controller.vo.conf.DistBatchReqVo;
import com.miplus.ccrm.core.controller.vo.conf.DistBatchResVo;
import com.miplus.ccrm.core.pojo.CmTrunk;
import com.miplus.ccrm.core.pojo.CmTrunkLink;
import com.miplus.ccrm.core.pojo.CpCalllist;
import com.miplus.ccrm.core.security.JCommonData;
import com.miplus.ccrm.core.service.conf.*;
import com.miplus.ccrm.core.service.cust.ConBlacklistService;
import com.miplus.ccrm.core.service.strategy.CpCalllistService;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 2-1.配置服务接口
 */
@Slf4j
@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
@RequestMapping("/conf")
public class ConfController {
    @Resource
    private MsgDefineService msgDefineService;
    @Resource
    private WfWorkflowService wfWorkflowService;
    @Resource
    private WfStepsService wfStepsService;
    @Resource
    private WfActionsService wfActionsService;
    @Resource
    private MsgAnnoucesService msgAnnoucesService;
    @Resource
    private SysOutsourcingService sysOutsourcingService;
    @Resource
    private SysPostService sysPostService;
    @Resource
    private WfCasesService wfCasesService;
    @Resource
    private WfCaseactionsService wfCaseactionsService;
    @Resource
    private FiDistbatchHistService fiDistbatchHistService;
    @Resource
    private MsgAlertsService msgAlertsService;
    @Resource
    private FiPenaltyHistService fiPenaltyHistService;
    @Resource
    private JCommonData jCommonData;

    @Resource
    private IouProductService iouProductService;
    @Resource
    private IouPorductApiService iouPorductApiService;

    @Resource
    private ConBlacklistService conBlacklistService;

    @Resource
    private SipRegistrationsService sipRegistrationsService;

    @Resource
    private SysUserService sysUserService;

    @Resource
    private SysDeviceHistService sysDeviceHistService;


    @Resource
    private CmTrunkLinkService cmTrunkLinkService;


    @Resource
    private CmTrunkService cmTrunkService;



    @Resource
    private CpCalllistService cpCalllistService;

    /**
     * 产品管理LIST
     * @param reqVo
     * @return
     */
    @GetMapping("/productPage")
    public R<PageData<IouProductPageResVo>> productPage(@Validated IouProductPageReqVo reqVo){
        return R.SuccessPage(iouProductService.productPage(reqVo));
    }
    /**
     * 下拉框产品管理LIST
     * @return
     */
    @GetMapping("/selectProduct")
    public R<List<IouSelectProductResVo>> selectProduct(){
        return R.Success(iouProductService.selectProduct());
    }

    /**
     * 下拉框商户名称LIST
     * @return
     */
    @GetMapping("/selectMerchant")
    public R<List<IouSelectProductResVo>> selectMerchant(){
        return R.Success(iouProductService.selectMerchant());
    }

    /**
     * 录入产品信息
     * @param reqVo
     * @return
     */
    @PostMapping("/productInsert")
    public R<CmdResVo>productInsert(@RequestBody @Validated IouProductEditReqVo reqVo){
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(iouProductService.productInsert(usrid,reqVo));
    }

    /**
     * 获取产品可用联机API
     * productId 产品编号
     * @param reqVo
     * @return
     */
    @PostMapping("/getProductApiList")
    public R<List<String>>getProductApiList(@RequestBody @Validated IouProductEditReqVo reqVo){
        return R.Success(iouPorductApiService.getProductApiList(reqVo.getProductId(), reqVo.getMerchantId()));
    }

    /**
     * 编辑产品信息
     * @param reqVo
     * @return
     */
    @PostMapping("/productEdit")
    public R<CmdResVo>productEdit(@RequestBody @Validated IouProductEditReqVo reqVo){
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(iouProductService.productEdit(usrid,reqVo));
    }

    /**
     * 删除产品信息
     * @param reqVo
     * @return
     */
    @PostMapping("/productDelete")
    public R<CmdResVo>productDelete(@RequestBody @Validated IouProductEditReqVo reqVo){
       // String usrid= jCommonData.getCurrUsrID();
        return R.Success(iouProductService.productDelete(reqVo));
    }
    /**
     * 取消息模板信息LIST
     */
    @GetMapping("/msgTempList")
    public R<PageData<MsgTmpResVo>> msgTempList(@Validated MsgTmpReqVo msgTmpReqVo){
        return R.SuccessPage(msgDefineService.msgTempList(msgTmpReqVo));
    }

    /**
     * 取消息模板详细信息One
     */
    @GetMapping("/getMsgTmpInfo")
    public R<MsgTmpResVo> getMsgTmpInfo(@RequestParam @NotNull String tempID){
        return R.Success(msgDefineService.getMsgTmpInfo(tempID));
    }

    /**
     * 取消息模板Value.LIST
     * sendmode 发送模式,1=自动，2=手动
     * channel 模板渠道 1=短信，2=AI
     */
    @GetMapping("/getMsgTmpList")
    public R<List<LabelResVo>> getMsgTmpList(@RequestParam String sendmode,@RequestParam String channel){
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(msgDefineService.getMsgTmpList(null,null,usrid,sendmode,
                StringUtils.isNotEmpty(channel)? Integer.parseInt(channel):1,null));
    }

    /**
     * 取消息模板Value.LIST
     * sendmode 发送模式,1=自动，2=手动
     * ficaseid 案件id
     * contactnumebr:联系人ID
     */
    @GetMapping("/getMsgTmpListFilter")
    public R<List<LabelResVo>> getMsgTmpList(@RequestParam @NotNull String sendmode,@RequestParam String ficaseid, @RequestParam String contactnumber){
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(msgDefineService.getMsgTmpList(ficaseid,contactnumber,usrid,sendmode,1,null));
    }

    /**
     * 取消息模板Value.LIST
     * sendmode 发送模式,1=自动，2=手动
     */
    @GetMapping("/getMsgTmpListAll")
    public R<List<LabelResVo>> getMsgTmpListAll(@RequestParam @NotNull String sendmode){
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(msgDefineService.getMsgTmpListAll(sendmode,1));
    }

    /**
     * 添加消息模板
     */
    @PostMapping("/msgTempInsert")
    public R<CmdResVo> insertMsgTmp(@RequestBody @Validated MsgTmpEditReqVo msgTmpEditReqVo) {
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(msgDefineService.insertMsgTmp(usrid, msgTmpEditReqVo));
    }

    /**
     * 修改消息模板
     */
    @PostMapping("/msgTempUpdate")
    public R<CmdResVo> updateMsgTmp(@RequestBody @Validated MsgTmpEditReqVo msgTmpEditReqVo) {
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(msgDefineService.updateMsgTmp(usrid,msgTmpEditReqVo));
    }
    /**
     * 修改消息模板
     */
    @PostMapping("/msgTempAdd")
    public R<CmdResVo> addMsgTmp(@RequestBody @Validated MsgTmpEditReqVo msgTmpEditReqVo) {
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(msgDefineService.addMsgTmp(usrid,msgTmpEditReqVo));
    }
    /**
     * 删除消息模板
     */
    @PostMapping("/msgTempDelete")
    public R<CmdResVo> deleteMsgTmp(@RequestBody @Validated DeleteReqVo deleteReqVo) {
        return R.Success(msgDefineService.deleteMsgTmp(deleteReqVo.getId()));
    }

    /**
     * 更新消息模板状态
     */
    @PostMapping("/msgTmpStatusUpdate")
    public R<CmdResVo> updateMsgTmpStatus(@RequestBody @Validated UpdateStateReqVo updateStateReqVo) {
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(msgDefineService.updateStatus(usrid, updateStateReqVo.getId(),updateStateReqVo.getStatus()));
    }

    /**
     * 取工作流LIST
     */
    @GetMapping("/workFlowList")
    public R<PageData<WfResVo>> workFlowList(@Validated WfReqVo wfReqVo){
        return R.SuccessPage(wfWorkflowService.workFlowList(wfReqVo));
    }

    /**
     * 取工作流Value.LIST
     */
    @GetMapping("/getWorkFlowList")
    public R<List<LabelResVo>> getWorkFlowList(){
        return R.Success(wfWorkflowService.getWorkFlowList());
    }

    /**
     * 取工作流节点状态字典
     */
    @GetMapping("/getNamesValuesByWfid")
    public R<List<LabelResVo>> getNamesValuesByWfid(@RequestParam @NotNull Integer wfid){
        return R.Success(wfWorkflowService.getNamesValuesByWfid(wfid));
    }

    /**
     * 添加工作流
     */
    @PostMapping("/insertFlowList")
    public R<CmdResVo> insertFlowList(@RequestBody @Validated WfEditReqVo wfEditReqVo) {
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(wfWorkflowService.insertWorkFlow(usrid,wfEditReqVo));
    }

    /**
     * 修改工作流
     */
    @PostMapping("/updateFlowList")
    public R<CmdResVo> updateFlowList(@RequestBody @Validated WfEditReqVo wfEditReqVo) {
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(wfWorkflowService.updateWorkFlow(usrid,wfEditReqVo));
    }

    /**
     * 删除工作流
     */
    @PostMapping("/deleteFlowList")
    public R<CmdResVo> deleteFlowList(@RequestBody @Validated DeleteReqVo deleteReqVo) {
        return R.Success(wfWorkflowService.deleteWorkFlow(deleteReqVo.getId()));
    }

    /**
     * 取工作流节点LIST
     */
    @GetMapping("/wfStepList")
    public R<PageData<WfStepResVo>> wfStepList(@Validated WfStepReqVo wfStepReqVo){
        return R.SuccessPage(wfStepsService.wfStepList(wfStepReqVo));
    }

    /**
     * 取工作流下一个节点LIST
     */
    @GetMapping("/getStepIdList")
    public R<List<LabelResVo>> getStepIdList(@RequestParam @NotNull Integer wfid){
        return R.Success(wfStepsService.getStepIdList(wfid));
    }

    /**
     * 取工作流下一个节点LIST
     */
    @GetMapping("/getTaskStepList")
    public R<List<LabelResVo>> getTaskStepList(@RequestParam @NotNull String clid){
        CpCalllist  cc = cpCalllistService.getById(clid);
        return R.Success(wfStepsService.getStepIdList(cc.getWfid()));
    }
    /**
     * 添加工作流节点
     */
    @PostMapping("/insertWfStep")
    public R<CmdResVo> insertWfStep(@RequestBody @Validated WfStepEditReqVo wfStepEditReqVo) {
        return R.Success(wfStepsService.insertStep(wfStepEditReqVo));
    }

    /**
     * 修改工作流节点
     */
    @PostMapping("/updateWfStep")
    public R<CmdResVo> updateWfStep(@RequestBody @Validated WfStepEditReqVo wfStepEditReqVo) {
        return R.Success(wfStepsService.updateStep(wfStepEditReqVo));
    }

    /**
     * 删除工作流节点
     */
    @PostMapping("/deleteWfStep")
    public R<CmdResVo> deleteWfStep(@RequestBody @Validated DeleteReqVo deleteReqVo) {
        return R.Success(wfStepsService.deleteStep(deleteReqVo.getId()));
    }

    /**
     * 取工作流动作LIST
     */
    @GetMapping("/wfActionList")
    public R<PageData<WfActionResVo>> wfActionList(@Validated WfActionReqVo wfActionReqVo){
        return R.SuccessPage(wfActionsService.wfActionList(wfActionReqVo));
    }

    /**
     * 添加工作流动作
     */
    @PostMapping("/insertWfAction")
    public R<CmdResVo> insertWfAction(@RequestBody @Validated WfActEditReqVo wfActEditReqVo) {
        return R.Success(wfActionsService.insertAction(wfActEditReqVo));
    }

    /**
     * 修改工作流动作
     */
    @PostMapping("/updateWfAction")
    public R<CmdResVo> updateWfAction(@RequestBody @Validated WfActEditReqVo wfActEditReqVo) {
        return R.Success(wfActionsService.updateAction(wfActEditReqVo));
    }

    /**
     * 删除工作流动作
     */
    @PostMapping("/deleteWfAction")
    public R<CmdResVo> deleteWfAction(@RequestBody @Validated DeleteReqVo deleteReqVo) {
        return R.Success(wfActionsService.deleteAction(deleteReqVo.getId()));
    }

    /**
     * 取工作流实例动作ID.LIST
     */
    @GetMapping("/getActionList")
    public R<List<WfActResVo>> getActionList(@Validated WfActReqVo wfActReqVo){
        JSysUser user= jCommonData.getCurrUsr();
        return R.Success(wfCasesService.getActionList(user,wfActReqVo));
    }

    @GetMapping("/getStepActions")
    public R<List<WfActResVo>> getStepActions(@Validated Integer stepid){
        JSysUser user= jCommonData.getCurrUsr();
        return R.Success(wfActionsService.getStepActions(user,stepid));
    }
    /**
     * 取工作流实例过程
     */
    @GetMapping("/wfProcessList")
    public R<List<WfCaseProcResVo>> wfProcessList(@Validated WfCaseProcReqVo wfCaseProcReqVo){
        return R.Success(wfCaseactionsService.wfProcessList(wfCaseProcReqVo));
    }

    /**
     * 取公告管理LIST
     */
    @GetMapping("/annouceList")
    public R<PageData<AnnoResVo>> msgAnnouceList(@Validated AnnoReqVo annoReqVo){
        String usrid= jCommonData.getCurrUsrID();
        return R.SuccessPage(msgAnnoucesService.msgAnnoList(usrid,annoReqVo));
    }

    /**
     * 取公告查看LIST
     */
    @GetMapping("/annouceViewList")
    public R<PageData<AnnoResVo>> msgAnnoViewList(@Validated AnnoReqVo annoReqVo){
        String usrid= jCommonData.getCurrUsrID();
        return R.SuccessPage(msgAnnoucesService.msgAnnoViewList(usrid,annoReqVo));
    }

    /**
     * 取公告详细
     */
    @GetMapping("/annouceInfo")
    public R<AnnoResVo> msgAnnouceInfo(@RequestParam @NotNull Integer annouceid){
        return R.Success(msgAnnoucesService.msgAnnoInfo(annouceid));
    }

    /**
     * 添加公告
     */
    @PostMapping("/anouceInsert")
    public R<CmdResVo> insertAnnouce(@RequestBody @Validated AnnoEditReqVo annoEditReqVo) {
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(msgAnnoucesService.insertAnno(usrid,annoEditReqVo));
    }

    /**
     * 修改公告
     */
    @PostMapping("/annouceUpdate")
    public R<CmdResVo> updateAnnouce(@RequestBody @Validated AnnoEditReqVo annoEditReqVo) {
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(msgAnnoucesService.updateAnno(usrid,annoEditReqVo));
    }

    /**
     * 删除公告
     */
    @PostMapping("/annouceDelete")
    public R<CmdResVo> deleteAnnouce(@RequestBody @Validated DeleteReqVo deleteReqVo) {
        return R.Success(msgAnnoucesService.deleteAnno(Integer.parseInt(deleteReqVo.getId())));
    }

    /**
     * 取消息GRID
     */
    @GetMapping("/alertViewList")
    public R<PageData<AlertResVo>> msgAlertViewList(@Validated AlertReqVo alertReqVo){
        String usrid= jCommonData.getCurrUsrID();
        return R.SuccessPage(msgAlertsService.msgAlertViewList(usrid,alertReqVo));
    }

    /**
     * 消息已读
     */
    @PostMapping("/alertReaded")
    public R<CmdResVo> msgAlertReaded(@RequestBody @Validated AlertReadVo alertReadVo) {
        return R.Success(msgAlertsService.msgAlertReaded(alertReadVo.getAlertid()));
    }

    /**
     * 公告已读
     */
    @PostMapping("/annouceReaded")
    public R<CmdResVo> annouceReaded(@RequestBody @Validated AnnoReadVo annoReadVo) {
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(msgAnnoucesService.annouceReaded(usrid,annoReadVo.getAnnouceid()));
    }

    /**
     * 取我可看的未读公告数
     */
    @GetMapping("/getAnnoNoReadCount")
    public R<CmdResVo> getAnnoNoReadCount(){
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(msgAnnoucesService.getAnnoNoReadCount(usrid));
    }

    /**
     * 取我的未读消息数
     */
    @GetMapping("/getAlertNoReadCount")
    public R<CmdResVo> getAlertNoReadCount(){
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(msgAlertsService.getAlertNoReadCount(usrid));
    }


    /**
     * 取委外机构LIST
     */
    @GetMapping("/outsourcingList")
    public R<PageData<OutGrpResVo>> outsourcingList(@Validated OutGrpReqVo outGrpReqVo){
        String usrid= jCommonData.getCurrUsrID();
        return R.SuccessPage(sysOutsourcingService.outSourcingList(usrid,outGrpReqVo));
    }

    /**
     * 添加委外机构
     */
    @PostMapping("/outsourcingInsert")
    public R<CmdResVo> outsourcingInsert(@RequestBody @Validated OutGrpEditVo outGrpEditVo) {
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(sysOutsourcingService.outSourcingInsert(usrid,outGrpEditVo));
    }

    /**
     * 修改委外机构
     */
    @PostMapping("/outsourcingUpdate")
    public R<CmdResVo> outsourcingUpdate(@RequestBody @Validated OutGrpEditVo outGrpEditVo) {
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(sysOutsourcingService.outSourcingUpdate(usrid,outGrpEditVo));
    }

    /**
     * 删除委外机构
     */
    @PostMapping("/outsourcingDelete")
    public R<CmdResVo> outsourcingDelete(@RequestBody @Validated OutGrpIDVo outGrpIDVo) {
        return R.Success(sysOutsourcingService.outSourcingDelete(outGrpIDVo.getGrpid()));
    }

    /**
     * 修改委外机构状态
     */
    @PostMapping("/outsourcingSetStatus")
    public R<CmdResVo> outsourcingSetStatus(@RequestBody @Validated OutGrpStatusVo outGrpStatusVo) {
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(sysOutsourcingService.outSourcingSetStatus(
                usrid,outGrpStatusVo.getGrpid(),outGrpStatusVo.getStatus()
        ));
    }

    /**
     * 取地址省LIST
     */
    @GetMapping("/getProvinceList")
    public R<List<LabelResVo>> getProvinceList(){
        return R.Success(sysPostService.getProvinceList());
    }

    /**
     * 取省对应的市LIST
     */
    @GetMapping("/getCityList")
    public R<List<LabelResVo>> getCityList(@RequestParam @NotNull String province){
        return R.Success(sysPostService.getCityList(province));
    }

    /**
     * 取市对应的区县LIST
     */
    @GetMapping("/getDistrictList")
    public R<List<LabelResVo>> getDistrictList(@RequestParam @NotNull String city){
        return R.Success(sysPostService.getDistrictList(city));
    }

    /**
     * 取地址省市区Tree
     */
    @GetMapping("/getPostTree")
    public R<List<PostTreeResVo>> getPostTree(){
        return R.Success(sysPostService.getPostTree());
    }

    /**
     * 取分案批次历史GRID
     */
    @GetMapping("/fiDistBatchList")
    public R<PageData<DistBatchResVo>> fiDistBatchList(@Validated DistBatchReqVo distBatchReqVo){
        return R.SuccessPage(fiDistbatchHistService.distBatchList(distBatchReqVo));
    }

    /**
     * 取分案批次明细GRID
     */
    @GetMapping("/fiDistBatchDetailList")
    public R<PageData<DistBatchResVo>> fiDistBatchDetailList(@Validated DistBatchTailReqVo distBatchTailReqVo){
        return R.SuccessPage(fiDistbatchHistService.distBatchDetail(distBatchTailReqVo));
    }

    /**
     * 取分案批次历史ID.LIST
     */
    @GetMapping("/getDistBatchIDList")
    public R<List<LabelResVo>> getDistBatchList(){
        return R.Success(fiDistbatchHistService.getDistBatchList());
    }

    /**
     * 取罚扣项LIST
     */
    @GetMapping("/fiPenaltyList")
    public R<PageData<PenalResVo>> fiPenaltyList(@Validated PenalReqVo penalReqVo){
        return R.SuccessPage(fiPenaltyHistService.penaltyList(penalReqVo));
    }

    /**
     * 添加罚扣项
     */
    @PostMapping("/fiPenaltyInsert")
    public R<CmdResVo> fiPenaltyInsert(@RequestBody @Validated PenalEditVo penalEditVo) {
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(fiPenaltyHistService.penaltyInsert(usrid,penalEditVo));
    }

    /**
     * 修改罚扣项
     */
    @PostMapping("/fiPenaltyUpdate")
    public R<CmdResVo> fiPenaltyUpdate(@RequestBody @Validated PenalEditVo penalEditVo) {
        String usrid= jCommonData.getCurrUsrID();
        return R.Success(fiPenaltyHistService.penaltyUpdate(usrid,penalEditVo));
    }

    /**
     * 删除罚扣项
     */
    @PostMapping("/fiPenaltyDelete")
    public R<CmdResVo> fiPenaltyDelete(@RequestBody @Validated DeleteReqVo deleteReqVo) {
        return R.Success(fiPenaltyHistService.penaltyDelete(Integer.parseInt(deleteReqVo.getId())));
    }
    /**
     * 获取标签列表
     */
    @GetMapping("/getTagList")
    public R<List<LabelResVo>> getTagList(){

        return R.Success(fiDistbatchHistService.getDistBatchList()
        );
    }


    /**
     * 黑白名单配置
     * @param reqVo
     * @return
     */
    @PostMapping("/conBlackAddBatch")
    public R<CmdResVo>conBlackAddBatch(@RequestBody @Validated ConBlackAddReqVo reqVo){
        JSysUser user= jCommonData.getCurrUsr();
        return R.Success(conBlacklistService.conBlackAddBatch(user,reqVo));
    }

    /**
     * 黑白名单配置 编辑
     * @param reqVo
     * @return
     */
    @PostMapping("/conBlackEdit")
    public R<CmdResVo>conBlackEdit(@RequestBody @Validated ConBlackAddReqVo reqVo){
        JSysUser user= jCommonData.getCurrUsr();
        return R.Success(conBlacklistService.conBlackEdit(user,reqVo));
    }

    /**
     * 黑白名单配置 移除
     * @return
     */
    @PostMapping("/conBlackRemove")
    public R<CmdResVo>conBlackRemove(@RequestBody @Validated ConBlackDelReqVo reqVo){
        JSysUser user= jCommonData.getCurrUsr();
        return R.Success(conBlacklistService.conBlackRemove(user,reqVo));
    }


    /**
     * 黑白名单配置 LIST
     * @param reqVo
     * @return
     */
    @PostMapping("/conBlackPage")
    public R<PageData<ConBlackPageResVo>> conBlackPage(@RequestBody @Validated ConBlackPageReqVo reqVo){
        JSysUser user= jCommonData.getCurrUsr();
        return R.SuccessPage(conBlacklistService.conBlackPage(user,reqVo));
    }


    /**
     * SIP注册 配置
     * @return
     */
    @GetMapping("/getSipReg")
    public R<String> getSipReg(@RequestParam @NotNull String sipUser){

        return R.Success(sipRegistrationsService.getSipReg(sipUser));
    }

    /**
     * 导出外用户列表
     */
    @PostMapping("/expSysUser")
    public R<CmdResVo> expSysUser(@RequestBody @Validated UserInfoReqVo userInfoReqVo, HttpServletResponse response){
        JSysUser user= jCommonData.getCurrUsr();
        return R.Success(sysUserService.expUserInfo(user,userInfoReqVo,response));
    }

    /**
     * 导出外用户列表
     */
    @PostMapping("/expDeviceHist")
    public R<CmdResVo> expDeviceHist(@RequestBody @Validated DeviceHistReqVo deviceHistReqVo, HttpServletResponse response){
        JSysUser user= jCommonData.getCurrUsr();
        return R.Success(sysDeviceHistService.expDeviceHist(user,deviceHistReqVo,response));
    }

    /**
     * 增加线路
     */
    @PostMapping("/addCmTrunk")
    public R<CmdResVo> addCmTrunk(@RequestBody @Validated CmTrunk cmTrunk){
        JSysUser user= jCommonData.getCurrUsr();
        return R.Success(cmTrunkService.addCmTrunk(user.getUsrid(),cmTrunk));
    }
    /**
     *  更新线路
     */
    @PostMapping("/updateCmTrunk")
    public R<CmdResVo> updateCmTrunk(@RequestBody @Validated CmTrunk cmTrunk){
        JSysUser user= jCommonData.getCurrUsr();
        return R.Success(cmTrunkService.updateCmTrunk(user.getUsrid(),cmTrunk));
    }
    /**
     *  删除线路
     */
    @PostMapping("/deleteCmTrunk")
    public R<CmdResVo> deleteCmTrunk(@RequestBody @Validated CmTrunk cmTrunk){
        JSysUser user= jCommonData.getCurrUsr();
        return R.Success(cmTrunkService.deleteCmTrunk(user.getUsrid(),cmTrunk.getTrunkid()));
    }

    /**
     * 查询线路
     * @param cmTrunkReqVo
     * @return
     */
    @GetMapping("/selectCmTrunkList")
    public R<PageData<CmTrunk>> selectCmTrunkList(@Validated CmTrunkReqVo cmTrunkReqVo){
        return R.SuccessPage(cmTrunkService.selectCmTrunkList(cmTrunkReqVo));
    }

    /**
     * 有效的线路列表。
     * @return
     */
    @GetMapping("/getCmTrunkList")
    public R<List<LabelResVo>> getCmTrunkList(){
        return R.Success(cmTrunkService.getCmTrunkList());
    }
    /**
     * 增加线路配置
     */
    @PostMapping("/addCmTrunkLink")
    public R<CmdResVo> addCmTrunkLink(@RequestBody @Validated CmTrunkLinkEditVo cmTrunkLinkEditVo){
        JSysUser user= jCommonData.getCurrUsr();
        return R.Success(cmTrunkLinkService.addCmTrunkLink(user.getUsrid(),cmTrunkLinkEditVo));
    }
    /**
     *  更新线路配置
     */
    @PostMapping("/updateCmTrunkLink")
    public R<CmdResVo> updateCmTrunkLink(@RequestBody @Validated CmTrunkLink cmTrunkLink){
        JSysUser user= jCommonData.getCurrUsr();
        return R.Success(cmTrunkLinkService.updateCmTrunkLink(user.getUsrid(),cmTrunkLink));
    }
    /**
     *  删除线路配置
     */
    @PostMapping("/deleteCmTrunkLink")
    public R<CmdResVo> deleteCmTrunkLink(@RequestBody @Validated CmTrunkLink cmTrunkLink){
        JSysUser user= jCommonData.getCurrUsr();
        return R.Success(cmTrunkLinkService.deleteCmTrunkLink(cmTrunkLink.getId()));
    }

    /**
     * 查询线路配置
     * @param cmTrunkLinkReqVo
     * @return
     */
    @PostMapping("/selectCmTrunkLinkList")
    public R<PageData<CmTrunkLinkResVo>> selectCmTrunkLinkList(@RequestBody @Validated CmTrunkLinkReqVo cmTrunkLinkReqVo){
        return R.SuccessPage(cmTrunkLinkService.selectCmTrunkLinkList(cmTrunkLinkReqVo));
    }

    /**
     * 查询用户的可x。
     * @return
     */
    @GetMapping("/getCmTrunkLinkList")
    public R<List<LabelResVo>> getCmTrunkLinkList(@Validated String opeid){
        return R.Success(cmTrunkLinkService.getCmTrunkLinkList(opeid));
    }

}
